#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;
int T,n,m,L,V,maxp,cnt,sum,sumj,carj;
int d[N],v[N],a[N],p[N];
bool cj[N];
void judge()
{
    for(int i=1;i<=n;i++)
    {
        if(a[i]==0)
        {
            if(d[i]<=maxp&&v[i]>V)
            {
                cnt++;
            }
        }
        if(a[i]>0)
        {
            int dx=maxp-d[i];
            if(dx<0)    continue;
            if(2*a[i]*dx+v[i]*v[i]>V*V)
            {
                cnt++;
            }
        }
        if(a[i]<0)
        {
            int ai=abs(a[i]);
            if(v[i]<=V)  continue;
            if(d[i]>maxp)   continue;
            int pos=lower_bound(p+1,p+m+1,d[i])-p;
            int dx=p[pos]-d[i];
            if(dx*2*ai>v[i]*v[i]) continue;
            if(v[i]*v[i]-2*ai*dx>V*V)
            {
                if(cj[pos])
                {
                    sumj--;
                }
                cj[pos]=true;
                cnt++;sumj++;carj++;
            }
        }
    }
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    cin>>T;
    for(int i=1;i<=T;i++)
    {
        memset(cj,false,sizeof(cj));
        cnt=0;maxp=0;carj=0;sumj=0;
        cin>>n>>m>>L>>V;
        for(int j=1;j<=n;j++)
        {
            cin>>d[j]>>v[j]>>a[j];
        }
        for(int j=1;j<=m;j++)
        {
            cin>>p[j];
        }
        sort(p+1,p+m+1);
        maxp=p[m];
        judge();
        if(!carj)
        {
            sum=m-1;
            if(!cnt)    sum=m;
        }
        else
        {
            sum=m-sumj;
            if(!cnt)    sum=m;
        }
        cout<<cnt<<' '<<sum<<'\n';
    }
    return 0;
}
